

function registerButtons(){
    //获取信息
    let id = document.getElementById('studentId').value
    let name = document.getElementById('name').value
    let gender = document.getElementById('gender').value
    let college = document.getElementById('department').value
    let major =document.getElementById('major').value
    let grade = document.getElementById('grade').value
    let phone = document.getElementById('phone').value
    //登录密码
    let registerPassword = document.getElementById('registerPassword').value
    //确认密码
    let confirmPassword = document.getElementById('confirmPassword').value

    if(id === '' || name === '' || gender === ''  || college === '' || major === ''  || grade === '' || phone === '' || registerPassword === ''  || confirmPassword === '' ){
        alert("请完整的填写注册信息！")
    }

    else if(registerPassword !== confirmPassword){
        alert("两次密码不一样，请重新检查！")
    }else {


        // alert("开始进行ajax请求")
        //ajax请求对数据进行传输
        // alert(id+name+gender+college+major+grade+phone+registerPassword+college)


        $.ajax({
            url: 'http://localhost:8080/RegisterServerController',
            type: 'POST',
            data: { // 发送到后端的数据
                id: id,
                name: name,
                gender: gender,
                college: college,
                major: major,
                grade: grade,
                phone: phone,
                password: registerPassword
            },
            dataType: 'json', // 期望从后端接收的数据类型
            success: function (resp) {
                // console.log('接收到的数据:', resp)
                // alert("接收到的数据:" + resp.mes)
                //获取返回来的mes，判断注册成功还是已经有此账号：
                let flag = resp.mes;
                if (flag) {
                    alert("用户注册成功！返回登录！")
                } else {
                    alert("已有该学号/学工号的账号！")
                }

            },
            error: function (xhr, status, error) {
                // console.error('数据加载失败:', error);
                alert("数据加载失败")
            }
        });


    }


}
